<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" type="text/css">
  <link rel="stylesheet" href="https://static.pingendo.com/bootstrap/bootstrap-4.1.3.css">
  <title>注册</title>
</head>

<body>
  <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <div class="container"> <a class="navbar-brand" href="#">
        <i class="fa d-inline fa-lg fa-circle-o"></i>
        <b>SEHP资源共享平台</b>
      </a> <button class="navbar-toggler navbar-toggler-right border-0" type="button" data-toggle="collapse" data-target="#navbar11">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbar11">
          <ul class="navbar-nav mr-auto">
            <li class="nav-item"> <a class="nav-link" href="public.sehp">公共资源</a> </li>
            <li class="nav-item"> <a class="nav-link" href="private.sehp">我的资源</a> </li>
          </ul>
          <ul class="navbar-nav ml-auto" id="mynavbar">
            <li class="nav-item"> <a class="nav-link" href="myupload.sehp">我的上传</a> </li>
            <li class="nav-item"> <a class="nav-link" href="info.sehp">我的信息</a> </li>
          </ul> <a class="btn btn-primary navbar-btn ml-md-2" onclick="javascript:$('#myModal').modal()">上传文件</a>
        </div>
    </div>
  </nav>
  <div class="py-5 text-center">
    <div class="container">
      <div class="row">
        <div class="mx-auto col-lg-6 col-10">
          <h1>欢迎加入我们</h1>
          <p class="mb-3">注册加入我们，您将可以上传和共享自己的数据，也可以接受发布者为您提供的资源。</p>
          <div class="text-left">
            <div class="form-group"> <label for="form16">用户名</label> <input type="text" class="form-control" id="UserName" placeholder="请输入用户名" > </div>
            <div class="form-group"> <label for="form17">手机号码</label> <input type="text" class="form-control" id="Phone" placeholder="请输入手机号"> </div>
            <div class="form-group"> <label for="form18">邮件地址</label> <input type="email" class="form-control" id="Email" placeholder="请输入邮件地址"> </div>
            <div class="form-row">
              <div class="form-group col-md-6"> <label for="form19">密码</label> <input type="password" class="form-control" id="PassWord" placeholder="••••••••"> </div>
              <div class="form-group col-md-6"> <label for="form20">重复密码</label> <input type="password" class="form-control" id="PassWord2" placeholder="••••••••"> </div>
            </div>
            <div class="form-group">
              <div class="form-check"> <input class="form-check-input" type="checkbox" id="form21" value="on"> <label class="form-check-label" for="form21"> 我同意 <a href="#">SEHP资源共享平台用户协议</a> </label> </div>
            </div> <button type="submit" class="btn btn-primary btn-block btn-lg" onclick="Register()">注册</button>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="py-3">
    <div class="container">
      <div class="row">
        <div class="col-lg-4 col-6 p-3"> <i class="d-block fa fa-circle-o fa-5x text-primary"></i> </div>
        <div class="col-lg-4 col-6 p-3">
          <p class="mb-0"> <a href="http://chplang.com" target="_blank">SEHP官方网站</a> </p>
          <p class="mb-0"> <a href="https://github.com/leeli73/" target="_blank">Git仓库:https://github.com/leeli73/</a> </p>
          <p class="mb-0"> <a href="http://chplang.com" target="_blank">作者:Lee</a> </p>
          <p class="mb-0"> <a href="#">QQ:925776327</a> </p>
          <p class="mb-0"> <a href="mailto:leeli@live.cn">Email:leeli@live.cn</a> </p>
        </div>
        <div class="col-md-4 p-3">
          <h5> <b>关于</b> </h5>
          <p class="mb-0">超级拓展超文本预处理器-Super Expansion Hypertext Preprocessor。可将主流编程语言，如C/C++,Java,Python,Go,JS,易语言...直接嵌入HTML,无需进行新语法的学习,直接上手编写网站后端。</p>
        </div>
      </div>
    </div>
  </div>
  <!-- 模态框 -->
  <div class="modal fade" id="myModal">
      <div class="modal-dialog">
        <div class="modal-content">
     
          <!-- 模态框头部 -->
          <div class="modal-header">
            <h4 class="modal-title">资源上传</h4>
            <button type="button" class="close" data-dismiss="modal">&times;</button>
          </div>
     
          <!-- 模态框主体 -->
          <div class="modal-body">
            <iframe id="upm" src="http://127.0.0.1:8199/upload/show" width="100%" scrolling="no" frameborder="no"></iframe>
          </div>
     
          <!-- 模态框底部 -->
          <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
          </div>
     
        </div>
      </div>
    </div>
  <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.slim.min.js"></script>
  <script src="https://cdn.bootcss.com/popper.js/1.14.6/popper.js"></script>
  <script src="js/bootstrap.min.js"></script>
  <script>
      ShowWelcome()
      function Register()
      {
        var UserName = document.getElementById("UserName").value
        var PassWord = document.getElementById("PassWord").value
        var PassWord2 = document.getElementById("PassWord2").value
        var Phone = document.getElementById("Phone").value
        var Email = document.getElementById("Email").value
        if(UserName == "" || PassWord == "" || Phone == "" || Email == "")
        {
          alert("请输入正确的信息！")
          return
        }
        if(PassWord != PassWord2)
        {
          alert("两次密码不一致")
          return 
        }
        var xmlhttp=new XMLHttpRequest();
          xmlhttp.onreadystatechange=function()
          {
            if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {
              var Result = trimStr(xmlhttp.responseText)
              alert(Result);
              window.location = "index.html"
            }
          }
        var data = "UserName="+UserName+"&PassWord="+PassWord+"&Phone="+Phone+"&Email="+Email;
        xmlhttp.open("POST","lib/Register.sehp",true);
        xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
        xmlhttp.send(data);
      }
      function trimStr(str){
        return str.replace(/(^\s*)|(\s*$)/g,"");
      }
      function setCookie(name,value) 
      { 
        var Days = 30; 
        var exp = new Date(); 
        exp.setTime(exp.getTime() + Days*24*60*60*1000); 
        document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString(); 
      } 
      function getCookie(name) 
      { 
          var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
          if(arr=document.cookie.match(reg))
              return unescape(arr[2]); 
          else 
              return null; 
      }
      function delCookie(key) {
        var date = new Date();
        date.setTime(date.getTime() - 1);
        var delValue = getCookie(key);
        if (!!delValue) {
            document.cookie = key+'='+delValue+';expires='+date.toGMTString();
        }
    }
      function ShowWelcome()
      {
        if(getCookie("UserName") != null)
        {
          var elem_li = document.createElement('li'); // 生成一个 li元素
          elem_li.innerHTML = '<li class="nav-item"> <a class="nav-link" href="javascript:delCookie(\'UserName\');delCookie(\'Keyt\');window.location.href=\'index.html\';" id="Welcome">欢迎您,'+getCookie("UserName")+'</a> </li>'
          document.getElementById("mynavbar").appendChild(elem_li)
          var ifr = document.getElementById("upm");
          ifr.src="http://127.0.0.1:8199/upload/show?UserName="+getCookie("UserName");
          console.log(ifr.src)
        }
      }
    </script>
</body>

</html>